package com.wuhao.code.check.model

import com.aegis.mybatis.xmlless.annotations.JsonMappingProperty
import com.aegis.mybatis.xmlless.model.base.BaseSimpleClassWrapper
import com.aegis.mybatis.xmlless.resolver.ParameterResolver
import com.intellij.psi.PsiClass
import com.wuhao.code.check.hasAnnotation

/**
 * @author 吴昊
 * @date 2024/01/19
 * @version 1.0
 * @since v4.0.0
 */
class SimplePsiClassWrapper(private val psiClass: PsiClass) : BaseSimpleClassWrapper {

  override fun getJavaClass(): Class<*> {
    return Any::class.java
  }

  override fun isComplex(): Boolean {
    val allInterfaces = psiClass.getAllSuperClassNames()
    val fullName = psiClass.qualifiedName!!
    return !psiClass.isPrimitive()
        && !psiClass.hasAnnotation(JsonMappingProperty::class.java)
        && !psiClass.isEnum
        && !ParameterResolver.isNotComplexType(fullName, allInterfaces)
  }

  override fun isBoolean(): Boolean {
    return psiClass.name in listOf("boolean", "Boolean")
  }

  override fun isString(): Boolean {
    return psiClass.name == "String"
  }

}
